;;; -*- Mode: lisp; Package: CL-USER -*-

;;; Defsystem to convert the colnew Fortran code to Lisp
;;;
;;; Convert Fortran code to Lisp via
;;;
;;; (mk:oos "colnew-lisp" :compile :force t)

(in-package #-gcl #:cl-user #+gcl "CL-USER")

(require :f2cl)


(mk:define-language :f2cl-lisp
    :compiler #'f2cl:f2cl
    :loader #'identity
    :source-extension "f"
    :binary-extension "lisp")

(defparameter *colnew-root*
  (make-pathname :host (pathname-host *load-pathname*)
		 :directory (pathname-directory *load-pathname*)))

(mk:defsystem colnew-lisp
  :source-pathname *colnew-root*
  :components
  ((:module fortran
	    :source-extension "f"
	    :binary-pathname "lisp/"
	    :language :f2cl-lisp
	    :compiler-options (:common-as-array t :package :colnew)
	    :compile-only t
	    :components
	    (
	     ;; Linpack routines needed by colnew
	     (:file "dgesl"
		    :depends-on ("daxpy" "ddot"))
	     (:file "dgefa"
		    :depends-on ("idamax" "dscal" "daxpy"))
	     ;; BLAS routines needed by above
	     (:file "daxpy")
	     (:file "ddot")
	     (:file "dscal")
	     (:file "idamax")
	     ;; Simple compatibility to define all of the needed
	     ;; common blocks in one place.
	     (:file "compat"
		    :compiler-options (:declare-common t :common-as-array t
						       :package :colnew))
	     ;; COLNEW itself, broken down into one subroutine per
	     ;; file.
	     (:file "colnew"
		    :depends-on ("compat" "consts" "newmsh" "contrl"))
	     (:file "contrl"
		    :depends-on ("compat" "lsyslv" "skale" "errchk" "newmsh"))
	     (:file "skale"
		    :depends-on ("compat"))
	     (:file "newmsh"
		    :depends-on ("compat" "approx" "horder"))
	     (:file "consts"
		    :depends-on ("compat" "vmonde" "rkbas"))
	     (:file "errchk")
	     (:file "lsyslv"
		    :depends-on ("compat" "vwblok" "gblock" "gderiv" "fcblok"
					  "sbblok" "dmzsol"))
	     (:file "gderiv")
	     (:file "vwblok"
		    :depends-on ("compat" "dgesl" "dgefa"))
	     (:file "gblock"
		    :depends-on ("compat" "dgesl"))
	     (:file "appsln")
	     (:file "approx"
		    :depends-on ("compat"))
	     (:file "rkbas"
		    :depends-on ("compat"))
	     (:file "vmonde"
		    :depends-on ("compat"))
	     (:file "horder")
	     (:file "dmzsol"
		    :depends-on ("factrb" "shiftb"))
	     (:file "fcblok"
		    :depends-on ("factrb" "shiftb"))
	     (:file "factrb")
	     (:file "shiftb")
	     (:file "sbblok"
		    :depends-on ("subfor" "subbak"))
	     (:file "subfor")
	     (:file "subbak")))))
